import type { LoginParams, LoginResult } from '@/interfaces/user';
import type { ApiResponse } from '@/interfaces/api'
import { createGetRequest, createPostRequest } from '@/utils/request'

export async function login(data: LoginParams): Promise<ApiResponse<LoginResult>> {
  return await createPostRequest('/login', data);
}

export async function fetchUserInfo(): Promise<ApiResponse<LoginResult>> {
  return await createGetRequest('/userInfo');
}

export async function changeSign(url: string) {
  return await createPostRequest('/changeSign', { signature: url });
}

export async function changePass({ before, after }) {
  return await createPostRequest('/changePass', { password: before, changepass: after });
}
